package com.example.book.controller;

import com.example.book.model.BookInfo;
import com.example.book.model.PageRequest;
import com.example.book.model.PageResult;
import com.example.book.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

@RestController
@RequestMapping("/book")
public class BookController {
    @Autowired
    BookService bookService;

    @RequestMapping("/addBook")
    public Boolean addBook(BookInfo bookInfo) {
        if (bookInfo != null) {
            bookService.addBook(bookInfo);
            return true;
        }
        return false;
    }
    @RequestMapping("/getList")
    public PageResult<BookInfo> getList(PageRequest pageRequest){
      PageResult<BookInfo> bookInfoPageResult=bookService.getList(pageRequest);
      return bookInfoPageResult;
    }
    @RequestMapping("/update")
    public Boolean update(BookInfo bookInfo){
       Integer integer= bookService.update(bookInfo);
       if(integer>0){
           return true;
       }
        return false;
    }
}
